package com.hksj.acm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.acm.service.AirConditioningAlarmService;
import com.hksj.acm.vo.AirConditioningAlarmVO;
import com.hksj.cbm.dto.AlarmDTO;
import com.hksj.cbm.dto.AlarmPageDTO;
import com.hksj.cbm.vo.AlarmRankingVO;
import com.hksj.cbm.vo.AlarmVO;
import com.hksj.common.core.model.Rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @author fjt
 * @data 2024/7/10 15:39
 * @describe
 */
@Api(tags = "空调机组-报警列表")
@RestController
@RequestMapping("/api/acm/alarm")
public class AirConditioningAlarmController {


    @Autowired
    private AirConditioningAlarmService airConditioningAlarmService;


    @PostMapping("/page")
    @ApiOperation(value = "报警记录分页查询", notes = "报警记录分页查询",response = AirConditioningAlarmVO.class)
    public Rest<IPage<AirConditioningAlarmVO>> pageAlarm(@RequestBody @Valid AlarmPageDTO dto){
        return Rest.ok(airConditioningAlarmService.pageAlarm(dto));
    }


    @PostMapping("/total")
    @ApiOperation(value = "报警次数", notes = "报警次数")
    public Rest<Integer> total(@RequestBody @Valid AlarmPageDTO dto){
        return Rest.ok(airConditioningAlarmService.total(dto));
    }


    @PostMapping("/top")
    @ApiOperation(value = "报警记录排名(前10)", notes = "报警记录排名(前10)",response = AlarmRankingVO.class)
    public Rest<List<AlarmRankingVO>> ranking(@RequestBody @Valid AlarmPageDTO dto){
        return Rest.ok(airConditioningAlarmService.ranking(dto));
    }


    @PostMapping("/exportList")
    @ApiOperation(value = "导出报警记录", notes = "导出报警记录")
    public void exportList(HttpServletResponse response, @RequestBody @Valid AlarmDTO dto){
        airConditioningAlarmService.exportList(response, dto);
    }


}
